<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:77:"D:\phpStudy\WWW\oa\public/../application/admin\view\myself\myselfapprove.html";i:1515486569;}*/ ?>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="renderer" content="webkit">
    <title>网站信息</title>
    <link rel="stylesheet" href="__CSS__/pintuer.css">
    <link rel="stylesheet" href="__CSS__/admin.css">
    <link rel="stylesheet" href="__STATIC__/css/layui.css">
    <script src="__STATIC__/layui.js"></script>
    <script src="__JS__/jquery.js"></script>
    <script src="__JS__/pintuer.js"></script>
</head>
<body>
<div class="panel admin-panel">
    <div class="panel-head"><strong><span class="icon-pencil-square-o"></span>我的申请</strong>&emsp;<a
            style="color: #3a4bfb;font-weight: bold " href="javascript:history.go(-1)">返回上一步</a></div>
    <div class="layui-tab layui-tab-card" style="width: 1100px;margin-top: auto;">
        <ul class="layui-tab-title">
            <li class="layui-this">费用报销申请</li>
            <li>付款申请</li>
            <li>考勤签到申请</li>
            <li>请假申请</li>
            <li>福利申请</li>
            <li>出差申请</li>
            <li>接待费用申请</li>
            <li>合同申请</li>
        </ul>
        <div class="layui-tab-content" style="height: 400px;">
            <div class="layui-tab-item layui-show">
                <table id="expense_reimbursement" lay-filter="expense_reimbursement"></table></div>
            <div class="layui-tab-item">
                <table id="payment_application_form" lay-filter="payment_application_form"></table>
            </div>
            <div class="layui-tab-item">暂未开通此功能</div>
            <div class="layui-tab-item">
                <table id="leaves_form" lay-filter="leaves_form"></table>
            </div>
            <div class="layui-tab-item">暂未开通此功能</div>
            <div class="layui-tab-item">暂未开通此功能</div>
            <div class="layui-tab-item">暂未开通此功能</div>
            <div class="layui-tab-item">
                <table id="contract_form" lay-filter="contract_form"></table>
            </div>
        </div>
    </div>

</div>
</body>
<script type="text/javascript" src="__JS__/showdate.js"></script>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">查看详情</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除/撤销</a>
</script>
<script>
    layui.use('element', function(){
        var $ = layui.jquery
            ,element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块

        //触发事件
        var active = {
            tabAdd: function(){
                //新增一个Tab项
                element.tabAdd('demo', {
                    title: '新选项'+ (Math.random()*1000|0) //用于演示
                    ,content: '内容'+ (Math.random()*1000|0)
                    ,id: new Date().getTime() //实际使用一般是规定好的id，这里以时间戳模拟下
                })
            }

        };

        $('.site-demo-active').on('click', function(){
            var othis = $(this), type = othis.data('type');
            active[type] ? active[type].call(this, othis) : '';
        });

        //Hash地址的定位
        var layid = location.hash.replace(/^#test=/, '');
        element.tabChange('test', layid);

        element.on('tab(test)', function(elem){
            location.hash = 'test='+ $(this).attr('lay-id');
        });

    });
</script>
<script>
    layui.use(['table', 'laydate'], function () {
        var table = layui.table
            , laydate = layui.laydate;
        laydate.render({
            elem: '#reimbursement_time'
        });

        /*------------------------------------------------------*/
        //监听工具条付款申请
        table.on('tool(payment_application_form)', function (obj) {
            var data = obj.data;
            if (obj.event === 'edit') {
                window.location.replace("<?php echo url('Myself/myselfapprove_payment_application_form_save'); ?>?id=" + data.id)
                //layer.alert('编辑行：<br>' + JSON.stringify(data))
            } else if (obj.event === 'del') {
                //console.log(data.id);
                myselfapprove_del(data.id,data.type_approve);
                //layer.close(admin);
            }
        });
        //方法渲染table付款申请
        table.render({
            elem: '#payment_application_form'
            , height: 400
            ,initSort: {
                //排序字段，对应 cols 设定的各字段名
                field: 'id'
                //排序方式  asc: 升序、desc: 降序、null: 默认排序
                ,type: 'desc'
            }
            , url: "<?php echo url('Myself/myselfapprove_payment_application_form'); ?>"
            , cols: [[
                {field: 'id', title: '编号', width: 160, align: 'center', sort: true}
                , {field: 'type_approve', align: 'center', title: '单据类型', sort: true}
                , {field: 'payment_application_form_time', align: 'center', title: '申请时间', sort: true}
                , {field: 'apply_state', align: 'center', title: '审批状态', sort: true}
                , {fixed: 'right', title: '操作', align: 'center', toolbar: '#barDemo'}
            ]]
            , id: "test1"
            , page: {
                layout: ['count', 'limit', 'prev', 'page', 'next', 'skip']
                , curr: 1
            }
        });

        /*------------------------------------------------------*/
        //监听工具条费用报销申请
        table.on('tool(expense_reimbursement)', function (obj) {
            var data = obj.data;
            if (obj.event === 'edit') {
                window.location.replace("<?php echo url('Myself/myselfapprove_expense_reimbursement_save'); ?>?id=" + data.id)
                //layer.alert('编辑行：<br>' + JSON.stringify(data))
            } else if (obj.event === 'del') {
                //console.log(data.id);
                myselfapprove_del(data.id,data.type_approve);
                //layer.close(admin);
            }
        });
        //方法渲染table费用报销申请
        table.render({
            elem: '#expense_reimbursement'
            , height: 400
            ,initSort: {
                //排序字段，对应 cols 设定的各字段名
                field: 'id'
                //排序方式  asc: 升序、desc: 降序、null: 默认排序
                ,type: 'desc'
            }
            , url: "<?php echo url('Myself/myselfapprove_expense_reimbursement'); ?>"
            , cols: [[
                {field: 'id', title: '编号', width: 160, align: 'center', sort: true}
                , {field: 'type_approve', align: 'center', title: '单据类型', sort: true}
                , {field: 'reimbursement_time', align: 'center', title: '申请时间', sort: true}
                , {field: 'apply_state', align: 'center', title: '审批状态', sort: true}
                , {fixed: 'right', title: '操作', align: 'center', toolbar: '#barDemo'}
            ]]
            , id: "test2"
            , page: {
                layout: ['count', 'limit', 'prev', 'page', 'next', 'skip']
                , curr: 1
            }
        });

        /*------------------------------------------------------*/
        //监听工具条请假申请
        table.on('tool(leaves_form)', function (obj) {
            var data = obj.data;
            if (obj.event === 'edit') {
                window.location.replace("<?php echo url('Myself/myselfapprove_leaves_form_save'); ?>?id=" + data.id)
                //layer.alert('编辑行：<br>' + JSON.stringify(data))
            } else if (obj.event === 'del') {
                //console.log(data.id);
                myselfapprove_del(data.id,data.type_approve);
                //layer.close(admin);
            }
        });
        //方法渲染table请假申请
        table.render({
            elem: '#leaves_form'
            , height: 400
            ,initSort: {
                //排序字段，对应 cols 设定的各字段名
                field: 'id'
                //排序方式  asc: 升序、desc: 降序、null: 默认排序
                ,type: 'desc'
            }
            , url: "<?php echo url('Myself/myselfapprove_leaves_form'); ?>"
            , cols: [[
                {field: 'id', title: '编号', width: 160, align: 'center', sort: true}
                , {field: 'type_approve', align: 'center', title: '单据类型', sort: true}
                , {field: 'type_leave', align: 'center', title: '请假类型', sort: true}
                , {field: 'leave_form_time', align: 'center', title: '申请时间', sort: true}
                , {field: 'apply_state', align: 'center', title: '审批状态', sort: true}
                , {fixed: 'right', title: '操作', align: 'center', toolbar: '#barDemo'}
            ]]
            , id: "test3"
            , page: {
                layout: ['count', 'limit', 'prev', 'page', 'next', 'skip']
                , curr: 1
            }
        });

        /*------------------------------------------------------*/
        //监听工具条合同申请
        table.on('tool(contract_form)', function (obj) {
            var data = obj.data;
            if (obj.event === 'edit') {
                window.location.replace("<?php echo url('Myself/myselfapprove_contract_form_save'); ?>?id=" + data.id)
                //layer.alert('编辑行：<br>' + JSON.stringify(data))
            } else if (obj.event === 'del') {
                //console.log(data.id);
                myselfapprove_del(data.id,data.type_approve);
                //layer.close(admin);
            }
        });
        //方法渲染table请假申请
        table.render({
            elem: '#contract_form'
            , height: 400
            ,initSort: {
                //排序字段，对应 cols 设定的各字段名
                field: 'id'
                //排序方式  asc: 升序、desc: 降序、null: 默认排序
                ,type: 'desc'
            }
            , url: "<?php echo url('Myself/myselfapprove_contract_form'); ?>"
            , cols: [[
                {field: 'id', title: '编号', width: 85, align: 'center', sort: true}
                , {field: 'sub_region', align: 'center',width: 113, title: '提交区域', sort: true}
                , {field: 'contract_type', align: 'center',width: 112, title: '合同类型', sort: true}
                , {field: 'contract_approve_time', align: 'center',width: 140, title: '合同申请时间', sort: true}
                , {field: 'contract_name', align: 'center',width: 140, title: '合同名称', sort: true}
                , {field: 'contract_code', align: 'center',width: 113, title: '合同编号', sort: true}
                , {field: 'apply_state', align: 'center',width: 115, title: '审批状态', sort: true}
                , { title: '操作', align: 'center', toolbar: '#barDemo'}
            ]]
            , id: "test4"
            , page: {
                layout: ['count', 'limit', 'prev', 'page', 'next', 'skip']
                , curr: 1
            }
        });
        var $ = layui.$, active = {
            reload: function () {
                var reimbursement_time = $('#reimbursement_time');

                //执行重载
                table.reload('test', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    , where: {
                        key: {
                            reimbursement_time: reimbursement_time.val()
                        }
                    }
                });
            }
        };
        $('.demoTable .layui-btn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });
</script>
<script>
    //所有删除都调这一个方法
    function myselfapprove_del(id,type_approve) {
        //alert(type_approve);
        layui.use(['layer'], function () {
            var layer = layui.layer;
            layer.confirm('你确定要删除审批记录/撤销正在审批的申请吗?',{icon: 7, title: '提示'}, function (index) {
                $.ajax({
                    type: "post",
                    url: "<?php echo url('Myself/myselfapprove_del'); ?>",
                    data: {'id': id, 'submit': type_approve},
                    dataType: "json",
                    success: function (i) {
                        console.log(i);
                        if (i == 1) {
                            layer.msg('申请记录删除成功', {icon: 1});
                            layer.close(index);
                        }
                        else if (i == 2) {
                            layer.msg('撤销申请失败', {icon: 1});
                            layer.close(index);
                        }
                        else if (i == 3) {
                            layer.msg('申请已撤销', {icon: 1});
                            layer.close(index);
                        } else {
                            layer.msg('删除申请记录失败', {icon: 2});
                            layer.close(index);
                        }
                        setTimeout(function () {
                            //使用  setTimeout（）方法设定定时2000<a href="https://www.baidu.com/s?wd=%E6%AF%AB%E7%A7%92&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWuHn4n1DkmynYmhu9uhcd0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHf4PWmsrHRdnWckPWnkrHmkrf" target="_blank" class="baidu-highlight">毫秒</a>
                            window.location.reload();//页面刷新
                        }, 2000);
                    }
                });

            });
        });
    }
</script>
</html>